package client;

import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.font.Rectangle;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.BillboardControl;

/**
 *
 * @author Ben
//TASK: Fix floating text
 */
public class FloatingText
{
    String text;
    protected Spatial target;
    protected float x, y;
    protected BitmapText label;
    protected BillboardControl bb;

    public FloatingText (String inte, Spatial inta, float inx, float iny)
    {
        text = inte;
        target = inta;
        x = inx;
        y = iny;
        bb = new BillboardControl();
        bb.setAlignment(BillboardControl.Alignment.Camera);
        BitmapFont font = Main.appref.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
        label = new BitmapText(font,false);
        label.setText(text);
        label.setBox(new Rectangle(10,10,25,25));
        label.setQueueBucket(Bucket.Transparent);
        label.setSize(1f);
        label.setColor(ColorRGBA.White);
        label.setLocalTranslation(0, 1, 0);
        Node lock = new Node();
        lock.setLocalTranslation(target.getWorldTranslation());
        lock.attachChild(target);
        lock.attachChild(label);
        lock.addControl(bb);
        ControlTrail trail = new ControlTrail(lock, target, 10);
        lock.addControl(trail);
        Main.rendernode.attachChild(lock);
        Main.titles.add(this);
    }
}
